package Export;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

/**
 * @description:
 * @author: cyy
 **/
public class methodHSSF {
    //控制层
    /*public void exportCountAqZc(HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> parameters = parameters(request);

        String title = "资产准确性统计";
        String[] titleValues = new String[]{"行政区域", "在线资产总数","一机一档总数","资产数据准确性","","","","","","资产数据不准确性","","","","","","资产数据匹配率"};
        String[] titleValuesSecond = new String[]{"","","","DVR", "DVS","NVS","IPC","其他","合计","DVR", "DVS","NVS","IPC","其他","合计",""};
        String[] titleKeys = new String[]{"CivilName","ZcTotal","OmoaTotal","OnDVR", "OnDVS","OnNVS","OnIPC","OnOthers","OnTotal","OffDVR", "OffDVS","OffNVS","OffIPC","OffOthers","OffTotal","ZcRate"};
        List<Map<String, Object>> resultlist = icqSafetyCountService.getAlarmZcCount(parameters);;

        StringBuffer buffer = new StringBuffer();
        buffer.append(title);
        // 导出时间
        *//*SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        buffer.append(format.format(new Date()));*//*
        buffer.append(".xls");
        HSSFWorkbook wb = TrialExportUtilNew.getHSSFWorkbookZc(title, titleValues,titleValuesSecond,titleKeys, resultlist, null,1);
        OutputStream os = null;
        try {
            setResponseHeader(request, response, buffer.toString());
            os = response.getOutputStream();
            wb.write(os);
            os.flush();
            os.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (os != null) {
                    os.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }*/

    //控制层方法
    /*
    * public void setResponseHeader(HttpServletRequest request, HttpServletResponse response, String fileName) {
        try {
            String userAgent = request.getHeader("USER-AGENT");
            String finalFileName = null;
            if (StringUtils.contains(userAgent, "MSIE")) {// IE浏览器
                finalFileName = URLEncoder.encode(fileName, "UTF8");
            } else if (StringUtils.contains(userAgent, "Mozilla")) {// google,火狐浏览器
                finalFileName = new String(fileName.getBytes(), "ISO8859-1");
            } else {
                finalFileName = URLEncoder.encode(fileName, "UTF8");// 其他浏览器
            }
            response.setHeader("Content-Disposition", "attachment; filename=\"" + finalFileName + "\"");// 这里设置一下让浏览器弹出下载提示框，而不是直接在浏览器中打开
            response.setContentType("application/vnd.ms-excel");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    * */
}
